//
//  LSZObtainNotificationDetailsManager.m
//  JKFuYinProject
//
//  Created by 九酷 on 2018/8/30.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LSZObtainNotificationDetailsManager.h"

@implementation LSZObtainNotificationDetailsManager
-(id)initWithObtainNotificationDetails :(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        self.arrayData = [[NSMutableArray alloc]init];
        if ([[dic valueForKey:@"data"] isKindOfClass:[NSString class]]) {
            return self;
        }
        if ([[dic valueForKey:@"data"] isKindOfClass:[NSNumber class]]) {
            return self;
        }
        if (![dic valueForKey:@"data"]) {
            return self;
        }
        NSArray * arrayData = dic[@"data"][@"list"];
        NSMutableArray * AddArrayMg = [[NSMutableArray alloc]init];
        for (NSDictionary * diction in arrayData) {
            LSZObtainNotificationDetailsMg * mg = [[LSZObtainNotificationDetailsMg alloc]init];
            mg.id_id = NullStringjudgment(NSStr(diction[@"id"]));
            mg.uid = NullStringjudgment(NSStr(diction[@"uid"]));
            mg.tid = NullStringjudgment(NSStr(diction[@"tid"]));
            mg.from_uid = NullStringjudgment(NSStr(diction[@"from_uid"]));
            mg.type = NullStringjudgment(NSStr(diction[@"type"]));
            mg.tip = NullStringjudgment(NSStr(diction[@"tip"]));
            mg.msg = NullStringjudgment(NSStr(diction[@"msg"]));
            mg.kind = NullStringjudgment(NSStr(diction[@"kind"]));
            if ([[diction allKeys] containsObject:@"url"]) {
                mg.url = NullStringjudgment(NSStr(diction[@"url"]));
            }else{
                mg.url = @"";
            }
            if ([[diction allKeys] containsObject:@"thumb"]) {
                mg.thumb = NullStringjudgment(NSStr(diction[@"thumb"]));
            }else{
                mg.thumb = @"";
            }

            if ([[diction allKeys] containsObject:@"is_read"]) {
                mg.is_read = NullStringjudgment(NSStr(diction[@"is_read"]));
            }else{
                mg.is_read = @"";
            }
            NSArray *array = [diction[@"add_time"] componentsSeparatedByString:@" "]; //从字符A中分隔成2个元素的数组
            mg.add_time =  array[0];
            //发布者
            id from_user = diction[@"from_user"];
            if ([from_user isKindOfClass:[NSDictionary class]]) {
                if ([[from_user allKeys] containsObject:@"avatar"]) {
                    mg.avatar = NullStringjudgment(NSStr(diction[@"from_user"][@"avatar"]));
                    mg.username = NullStringjudgment(NSStr(diction[@"from_user"][@"username"]));
                }else{
                    mg.avatar = @"";
                    mg.username = @"";
                }
            }else{
                mg.avatar = @"";
                mg.username = @"";
            }

            //所属动态
            id dynamic = diction[@"dynamic"];
            if ([dynamic isKindOfClass:[NSDictionary class]]) {
                if ([[dynamic allKeys] containsObject:@"content"]) {
                    mg.dynamic_content = NullStringjudgment(NSStr(diction[@"dynamic"][@"content"]));
                }else{
                    mg.dynamic_content = @"";
                }
            }

            //发布者的评论
            id from_comment = diction[@"from_comment"];
            if ([from_comment isKindOfClass:[NSDictionary class]]) {
                if ([[from_comment allKeys] containsObject:@"content"]) {
                    mg.from_comment_content = NullStringjudgment(NSStr(diction[@"from_comment"][@"content"]));
                }else{
                    mg.from_comment_content = @"";
                }
            }
            //被动资源拥有者
            id user = diction[@"user"];
            if ([user isKindOfClass:[NSDictionary class]]) {
                if ([[user allKeys] containsObject:@"username"]) {
                    mg.user_username = NullStringjudgment(NSStr(diction[@"user"][@"username"]));
                }else{
                    mg.user_username = @"";
                }
                if ([[user allKeys] containsObject:@"uid"]) {
                    mg.user_uid = NullStringjudgment(NSStr(diction[@"user"][@"uid"]));
                }else{
                    mg.user_uid = @"";
                }
            }

            //comment_content 被回复/点赞的评论
            id content = diction[@"comment"];
            if ([content isKindOfClass:[NSDictionary class]]) {
                if ([[content allKeys] containsObject:@"content"]) {
                    mg.comment_content = NullStringjudgment(NSStr(diction[@"comment"][@"content"]));
                }else{
                    mg.comment_content = @"";
                }
            }

            [AddArrayMg addObject:mg];
        }
        self.arrayData = AddArrayMg;
    }
    return self;
}
@end
@implementation LSZObtainNotificationDetailsMg

@end
